package com.fr.base;

import java.io.File;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class ClassFinder
{
  public String className;
  public ArrayList jarFiles = new ArrayList();

  public ClassFinder()
  {
  }

  public ClassFinder(String paramString)
  {
    this.className = paramString;
  }

  public void setClassName(String paramString)
  {
    this.className = paramString;
  }

  public List findClass(String paramString, boolean paramBoolean)
  {
    searchDir(paramString, paramBoolean);
    return this.jarFiles;
  }

  protected void searchDir(String paramString, boolean paramBoolean)
  {
    File localFile;
    File[] arrayOfFile;
    int i;
    try
    {
      localFile = new File(paramString);
      if (!(localFile.isDirectory()))
        return;
      arrayOfFile = localFile.listFiles();
      label259: for (i = 0; i < arrayOfFile.length; ++i)
        if ((paramBoolean) && (arrayOfFile[i].isDirectory()))
        {
          searchDir(arrayOfFile[i].getAbsolutePath(), true);
        }
        else
        {
          Object localObject;
          String str1 = arrayOfFile[i].getAbsolutePath();
          if ((str1.endsWith(".jar")) || (str1.endsWith(".zip")))
          {
            localObject = new ZipFile(str1);
            Enumeration localEnumeration = ((ZipFile)localObject).entries();
            while (true)
            {
              String str2;
              do
              {
                if (!(localEnumeration.hasMoreElements()))
                  break label259;
                ZipEntry localZipEntry = (ZipEntry)localEnumeration.nextElement();
                str2 = getClassName(localZipEntry);
              }
              while ((!(str2.equals(this.className))) && (!(str2.equals(this.className + ".class"))));
              this.jarFiles.add(str1);
            }
          }
          if (str1.endsWith(".class"))
          {
            localObject = str1.replaceAll("\\\\", ".");
            if (((String)localObject).endsWith(this.className + ".class"))
              this.jarFiles.add(str1);
          }
        }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  public List getFilenames()
  {
    return this.jarFiles;
  }

  protected String getClassName(ZipEntry paramZipEntry)
  {
    StringBuffer localStringBuffer = new StringBuffer(paramZipEntry.getName().replace('/', '.'));
    return localStringBuffer.toString();
  }

  public static void main(String[] paramArrayOfString)
  {
    int i;
    ClassFinder localClassFinder = new ClassFinder("com.fr.util.Consts");
    localClassFinder.findClass("D:\\FineReport\\develop\\code", true);
    List localList = localClassFinder.findClass("D:\\FineReport\\develop\\java", true);
    if (localList.size() == 0)
      System.out.println("Not Found");
    else
      for (i = 0; i < localList.size(); ++i)
        System.out.println(localList.get(i));
  }
}